package com.laixu.estore.service;

import com.laixu.estore.bean.vo.CollectVO;
import com.laixu.estore.dao.CollectDao;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;

@Service // @Controller @Repository @Component
@RequiredArgsConstructor
@Slf4j
public class CollectService {
    @Value("${myIp}")
    private String myIp;
    @Autowired
    private final CollectDao collectDao;
    public void addCollect(Integer id, String userId) {
        collectDao.addCollect(id,userId);

    }

    public Object list(String userId) {
        List<CollectVO> list = collectDao.list(userId);
        for (CollectVO collectVO : list) {
            collectVO.setCover(myIp + collectVO.getCover());
        }
        return list;
    }

    public void delete(List<Integer> ids) {
        for (Integer id : ids) {
            collectDao.delete(id);
        }
    }
}
